import React, {useEffect, useState} from 'react';
import {
  View,
  Text,
  TouchableOpacity,
  TextInput,
  Image,
  ScrollView,
} from 'react-native';
import {useNavigation} from '@react-navigation/native';
import AreaView from '../../components/Layout/AreaView';
import BaseUrl from '../../config/BaseUrl';
import styles from './style';
import {Icon} from '@ant-design/react-native';
import {getAswPaperList} from '../../service/my';

const MyApply = () => {
  const navigation = useNavigation();
  const [pn, setPn] = useState(1);
  const [list, setList] = useState([]);
  useEffect(() => {
    getAswPaperList({pn}).then((res) => {
      console.log(res);
      setList(res.rows);
    });
  }, [pn]);
  return (
    <AreaView>
      <ScrollView showsVerticalScrollIndicator={false} style={styles.container}>
        <View style={styles.gap} />
        {(list || []).map((item) => (
          <View key={item.apId}>
            <View style={styles.top}>
              <View style={styles.dot_container}>
                <View style={styles.dot} />
              </View>
              <Text style={styles.time}>{item.createTime}</Text>
            </View>
            <View style={styles.bottom}>
              <View style={styles.line_container}>
                <View style={styles.line} />
              </View>
              <View style={styles.desc_container}>
                <View style={styles.prd_list}>
                  <Image
                    source={{uri: BaseUrl.imgurl + item.epImage}}
                    style={styles.history_cover}
                  />
                  <View style={styles.prd_info}>
                    <Text style={styles.prd_title}>{item.epTitle}</Text>
                    {/* <Text style={styles.prd_name}>詹老师</Text> */}
                    <Text numberOfLines={2} style={styles.prd_desc}>
                      <Text style={styles.prd_desc_title}>简介文字：</Text>
                      {item.epDesc}
                    </Text>
                  </View>
                </View>
                {/* <View style={styles.process}>
                  <Text style={styles.process_text}>
                    <Text style={styles.process_title}>学习进度：</Text>
                    您已经学习了23分11秒
                  </Text>
                  <Text style={styles.process_num}>已学习12%</Text>
                </View> */}
                <TouchableOpacity
                  onPress={() => {
                    navigation.push('QuesDetail', {
                      epId: item.epId,
                    });
                  }}
                  activeOpacity={1}
                  style={styles.btn_contoiner}>
                  <Text style={styles.btn_text}>进入练习</Text>
                  <Icon name="double-right" style={styles.icon_right} />
                </TouchableOpacity>
              </View>
            </View>
          </View>
        ))}
      </ScrollView>
    </AreaView>
  );
};

export default MyApply;
